﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="~/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/css/style.css" />
    <link href="~/assets/css/codemirror.css" rel="stylesheet" />
    <link rel="stylesheet" href="~/assets/css/ace.min.css" />
    <link rel="stylesheet" href="~/font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
      <link rel="stylesheet" href="~/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="~/js/jquery-1.9.1.min.js"></script>
    <script src="~/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="~/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="~/assets/js/typeahead-bs2.min.js"></script>
    <script src="~/assets/js/jquery.dataTables.min.js"></script>
    <script src="~/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="~/assets/layer/layer.js" type="text/javascript"></script>
    <script src="~/js/lrtk.js" type="text/javascript"></script>
    <script src="~/assets/layer/layer.js" type="text/javascript"></script>
    <script src="~/assets/laydate/laydate.js" type="text/javascript"></script>
    <!--自己-->
    <script src="~/layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="~/layui/css/layui.css" />
    <script src="~/js/Admin/administrator.js"></script>
    <script src="~/js/Admin/tablelayui.js" type="text/javascript" ></script>
    <title>管理员</title>
</head>
<body>
    <div class="page-content clearfix">
        <div class="administrator">
            <div class="d_Confirm_Order_style">
                <div class="search_style">

                    <ul class="search_content clearfix">
                        <li><label class="l_f">管理员名称</label><input name="" type="text" id="name" class="text_add" placeholder="" style=" width:400px" /></li>
                        <li><label class="l_f">添加时间</label><input class="inline laydate-icon" id="start" style=" margin-left:10px;" /></li>
                        <li style="width:90px;"><button class="layui-btn" id="butReload" data-type="reload" >搜索</button>
                    </ul>
                </div>
                <!--操作-->
                <div class="border clearfix">
                    <span class="l_f">
                        <a href="javascript:ovid()" id="administrator_add" class="btn btn-warning"><i class="fa fa-plus"></i> 添加功能列表</a>
                    </span>
                </div>
                <!--管理员列表-->
                <div class="clearfix administrator_style" id="administrator">

                 
                    <div  id="testIframe">
                        <table id="demo" class="layui-hide" lay-filter="test"></table>
                    </div>
                    
                    <script type="text/html" id="status">
                        <input type="checkbox" name="switch" value="{{d.AdminId}}" lay-skin="switch" lay-text="已启用|已禁用" lay-filter="
                               " {{ d.state == 1 ? 'checked' : '' }} />
                    </script>

                    <script type="text/html" id="barDemo">
                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                    </script>
                </div>
            </div>
        </div>

        <!--添加管理员-->

        <div id="add_administrator_style" class="add_menber" style="display:none">
            <form action="" method="post" id="form-admin-add">
                <div class="form-group">
                    <label class="form-label">功能：</label>
                    <div class="formControls ">
                        <span class="select-box" style="width:150px;">
                            <select class="select" name="admin-role" size="1" id="RoleId">
                                <option value="Add">增加</option>
                                <option value="Delete">删除</option>
                                <option value="Update">修改</option>
                                <option value="Select">查询</option>
                            </select>
                        </span>
                    </div>
                    <div class="col-4"> <span class="Validform_checktip" id="RoleName"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label "><span class="c-red">*</span>方法名称：</label>
                    <div class="formControls ">
                        <input type="text" class="input-text" value="" placeholder="" id="user-tel" name="user-tel" datatype="m" nullmsg="手机不能为空" />
                    </div>
                    <div class="col-4"> <span class="Validform_checktip" id="Telpop"></span></div>
                </div>
                <div class="form-group">
                    <label class="form-label">控制器名：</label>
                    <div class="formControls ">
                        <span class="select-box" style="width:150px;">
                            <select class="select" name="admin-role" size="1" id="MenuId">
                                @*<option value="1">AdminController</option>
                                <option value="2">HomeController</option>
                                <option value="3">LoginController</option>
                                <option value="4">MenuController</option>
                                <option value="5">ModuleController</option>
                                <option value="6">RoleController</option>*@
                                <option value="1">SystemController</option>
                            </select>
                        </span>
                    </div>
                </div>
                <div id="sign">
                    <input class="btn btn-primary radius" type="submit" id="Add_Administrator" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" />
                </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
    /*添加管理员*/
    $('#administrator_add').on('click', function () {
        //$("#btn_add").show();
        //$("#Update").hide();
        layer.open({
            type: 1,
            title: '添加管理员',
            area: ['700px', ''],
            shadeClose: false,
            content: $('#add_administrator_style'),
        });
    });
    //分页并显示数据
    layui.use(['table', 'form', 'jquery'], function () {
        var table = layui.table,
            form = layui.form,
            $ = layui.jquery;

        //第一个实例
        table.render({
            elem: '#demo'
            , height: 312
            , url: '/System/QueryFunctionAll' //数据接口
            , page: true
            , cols: [[ //表头
                { field: 'Id', title: '编号', width: 80, sort: true }
                , { field: 'MenuName', title: '菜单名称', width: 180, sort: true, }
                , { field: 'Name', title: '功能', width: 180 }
                , { field: 'ControllerName', title: '控制器方法名', width: 200, sort: true }
                , { field: 'ActionName', title: '方法名称', width: 200 }
                , { field: 'FunctionCode', title: '功能编码', width: 200 }
                , { fixed: 'right', title: '操作', width: 165, align: 'center', toolbar: '#barDemo' }
            ]]
            , page: true //开启分页
        });
        //监听显示状态操作
        form.on('switch(StatusDemo)', function (obj) {

            var data = {};
            data.LinkId = this.name;
            if (this.value == "false") {
                data.OrDisplay = true;
            } else if (this.value == "true") {
                data.OrDisplay = false;
            }
            $.ajax({
                url: "/System/FirendShipOrDisplayUpdate",
                type: "post",
                data: data,
                success: function (json) {
                    if (json.Success) {
                        layer.alert('操作成功！', {
                            title: '提示框',
                            icon: 1,
                        })

                    }
                    else {
                        layer.alert('操作失败！', {
                            title: '提示框',
                            icon: 1,
                        })
                    }
                }
            })
        });
    });



    layui.use(['table', 'form', 'jquery'], function () {
        var table = layui.table,
            form = layui.form,
            $ = layui.jquery;
        //监听工具条
        table.on('tool(test)', function (obj) {


            ///删除友情链接操作
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: "/System/DeleteFunction="+id,
                        type: "post",
                        success: function (json) {
                            if (json.Success) {
                                layer.alert('删除成功！', {
                                    title: '提示框',
                                    icon: 1,
                                });
                                obj.del();
                                layer.close(index);
                            } else {
                                layer.alert('删除失败!', {
                                    title: '提示框',
                                    icon: 1,
                                })
                            }
                        }

                    })
                });
            } else if (obj.event === 'edit') {
                layer.open({
                    type: 1,
                    title: '修改管理员',
                    area: ['700px', ''],
                    shadeClose: false,
                    content: $('#Update_administrator_style')

                });
                //修改友情链接操作
                $.ajax({
                    url: '/System/FirendShipLook',

                    type: "post",

                    success: function (json) {
                        $("#LinkId").val(data.LinkId);
                        $("#Sort").val(json.Sort);
                        $("#FriName").val(json.FriName);
                        $("#LinkAddress").val(json.LinkAddress);
                        $("#Describe").text(json.Describe)
                        $("#TelPhone").val(json.TelPhone);
                        $("#QQ").val(json.QQ);
                        $("#OrDisplay").val(json.OrDisplay);
                    }

                })

            }
        });
        $("#Update_Administrator").click(function () {
            var data = {};
            data.LinkId = $("#LinkId").val();
            data.Sort = $("#Sort").val();
            data.FriName = $("#FriName").val();
            data.LinkAddress = $("#LinkAddress").val();
            data.Describe = $("#Describe").text();
            data.TelPhone = $("#TelPhone").val();
            data.QQ = $("#QQ").val();
            data.OrDisplay = $("#OrDisplay").val();

            $.ajax({
                url: "/System/FirendShipUpdate?LinkId=" + data.LinkId,
                data: data,
                type: "post",


                success: function (json) {
                    if (json.Success) {
                        location.reload();
                        alert('修改成功');
                    } else {
                        alert('修改失败')
                    }
                }
            })
        })

        $("#Add_Administrator").click(function () {
            var data = {};
            data.Name = $("#MenuId").val();
            data.Sort = $("#Sort").val();
            data.FriName = $("#FriName").val();
            data.LinkAddress = $("#LinkAddress").val();
            data.Describe = $("#Describe").text();
            data.TelPhone = $("#TelPhone").val();
            data.QQ = $("#QQ").val();
            data.OrDisplay = $("#OrDisplay").val();

            $.ajax({
                url: "/System/FirendShipUpdate?LinkId=" + data.LinkId,
                data: data,
                type: "post",


                success: function (json) {
                    if (json.Success) {
                        location.reload();
                        alert('修改成功');
                    } else {
                        alert('修改失败')
                    }
                }
            })
        })
    })
</script>


